// createStore 创建store 数据管家
// applyMiddleware 添加中间件支持的方法，增强 action的处理能力
// combineReducers 合并多个reducer
import {
  legacy_createStore as createStore,
  applyMiddleware,
  combineReducers,
} from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';

// reducers
import { todos } from './reducer/todos';
const rootReducer = combineReducers({ todos });

export const store = createStore(
  rootReducer,
  composeWithDevTools(applyMiddleware(thunk))
);

// 根据 store.getState 方法动态的推到出我的 RootState 对象的类型（约束）
export type RootState = ReturnType<typeof store.getState>;
